package com.game.server.message.proto.execute;

import com.comm.ISession;

import com.game.majiang.config.DataManager;
import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.server.db.entity.XyClubInfo;
import com.game.server.db.entity.XyClubMemberInfo;
import com.game.server.db.entity.XyUnionInfo;
import com.game.server.message.proto.in.AbstractXYupdateUnionClubQuotaReq;
import com.game.server.message.proto.out.XYupdateUnionClubQuotaRsp;

public class XYupdateUnionClubQuotaReq extends AbstractXYupdateUnionClubQuotaReq {

    @Override
    public void Execute(ISession session) {
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());
        if (client != null&&client.checkClick(msgcode)) {
            XYupdateUnionClubQuotaRsp rsp = new XYupdateUnionClubQuotaRsp();
            rsp.setIsok(1);
            rsp.setClubid(this.clubid);
            rsp.setUnionid(this.unionid);
            rsp.setType(this.type);
            XyUnionInfo unionInfo = DataManager.getInstance().getMapUnion().get(this.unionid);
            XyClubInfo clubInfo = DataManager.getInstance().getMapClub().get(this.clubid);
            if (clubInfo!=null){
                XyClubInfo creatorClubInfo = DataManager.getInstance().getMapClub().get(unionInfo.getCreator_clubid());
                XyClubMemberInfo memberInfo = creatorClubInfo.getPlayer().get(client.getUserId());
                if (memberInfo!=null && memberInfo.getDel_type()==0 && (memberInfo.getIsManager()==1 || memberInfo.getIsManager()==2)){
                   int isok = clubInfo.updateUnionedu(this.type,this.val,this.unionid,memberInfo.getUid(),0,0);
                   rsp.setVal(this.val);
                   rsp.setIsok(isok);
                }
            }
            client.Send(rsp);
        }
    }

}
